#include <algorithm>
#include "fbitmap.hpp"


using namespace std;


FBitmap::FBitmap(int width, int height)
{
    _height = height;
    _width = width;
    _bm.resize(this->components());
}


FBitmap::FBitmap(const FBitmap &that)
{
    _height = that._height;
    _width = that._width;
    _bm = that._bm;
}


int FBitmap::width(void) const
{
    return _width;
}


int FBitmap::height(void) const
{
    return _height;
}


int FBitmap::pixels(void) const
{
    return _height*_width;
}


int FBitmap::components(void) const
{
    return _height*_width*3;
}


void FBitmap::set_pixel(int row, int col, float r, float g, float b)
{
    int pos = (row*_width+col)*3;
    _bm[pos] = r;
    _bm[pos+1] = g;
    _bm[pos+2] = b;
}


const float *FBitmap::c_ptr(void) const
{
    return &_bm[0];
}
